New Posts  All Forums:Forum Nav:

Python question - Page 3

post #21 of 28
Quote:
Originally Posted by Coma View Post

Code:
if keyValue == ("/r"):
\r is a carriage return, not /r. "/r" is a two character string. getch() returns a single character, and your if checks if that character is equal to "/r". which is never true.
Why are you using getch? You shouldn't use DLLs directly unless you have a very good reason. Use raw_input instead...

+1 on the raw_input... these DLL's seem to only like console...
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
post #22 of 28
Can you not use ASCII number references in Python via premade packages? (Learning Python as well, but I know in ADA you can use something like this because it is covered in character handling packages)

example:
Code:
if Is_Control = 13 then
    Ada.Text_IO.Put ("True");

Carriage return is 13 in dec and Is_Control is the predefined character handling package.

I should note if anyone is confused as to what character handling falls under it would be consided a function. You would just have to make sure you imported the package.
Edited by Bobicon - 8/11/12 at 6:28pm
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
post #23 of 28
Quote:
Originally Posted by Bobicon View Post

Can you not use ASCII number references in Python via premade packages? (Learning Python as well, but I know in ADA you can use something like this because it is covered in character handling packages)
example:
Code:
if Is_Control = 13 then
    Ada.Text_IO.Put ("True");
Carriage return is 13 in dec and Is_Control is the predefined character handling package.
I should note if anyone is confused as to what character handling falls under it would be consided a function. You would just have to make sure you imported the package.

it works the same. It's just not recognizing it because I think the dll doesn't work properly from anything but the console. raw_input works the best for me for trying to do something like this since get_ch is odd. a would be 97and A would be 65 (-32 from a).

I find get_ch will be collecting 255 all the time forever.
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
post #24 of 28
Quote:
Originally Posted by JQuantum View Post

it works the same. It's just not recognizing it because I think the dll doesn't work properly from anything but the console. raw_input works the best for me for trying to do something like this since get_ch is odd. a would be 97and A would be 65 (-32 from a).
I find get_ch will be collecting 255 all the time forever.

I looked at it again today and I wrote something simple up that says 'Pressed Enter' When the carriage return is pressed. Not sure if this is fully what you wanted it to do. (Not sure if you wanted a counter for this or if this needs to be run outside of idle). It may also need an outer loop or the loop parameters changed depending on how you use it.

If anyone has any corrections or anything that could streamline it feel free to add or correct me.
Code:
x = ''
while x !=chr(13):
    raw_input(x)
    if chr(13):
        print 'Pressed Enter'

What I would like to know is that it was forcing me to initialize X which is fine for me, but it was printing at the start as to what x was initialized to. I even tried making it a null character, but it would still print it.
Edited by Bobicon - 8/12/12 at 4:40pm
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
post #25 of 28

http://code.activestate.com/lists/python-list/222924/

 

That clearly explains what's being done wrong here. If you run this code from the console, "python.exe" is used to execute the code, but if you run it from IDLE (and probably other IDEs too), "pythonw.exe" is used. Both can be found in the folder in which Python is installed.

 

If you want it to run correctly, save the .py file onto your desktop (or anywhere else) and then double-click on it from there instead of running it in an IDE. The code will automatically be executed from the console and it will work fine.

 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
post #26 of 28
Quote:
Originally Posted by Bobicon View Post

I looked at it again today and I wrote something simple up that says 'Pressed Enter' When the carriage return is pressed. Not sure if this is fully what you wanted it to do. (Not sure if you wanted a counter for this or if this needs to be run outside of idle). It may also need an outer loop or the loop parameters changed depending on how you use it.
If anyone has any corrections or anything that could streamline it feel free to add or correct me.
Code:
x = ''
while x !=chr(13):
    raw_input(x)
    if chr(13):
        print 'Pressed Enter'
What I would like to know is that it was forcing me to initialize X which is fine for me, but it was printing at the start as to what x was initialized to. I even tried making it a null character, but it would still print it.


Not my thread so I don't know.
Quote:
Originally Posted by {Unregistered} View Post

http://code.activestate.com/lists/python-list/222924/

That clearly explains what's being done wrong here. If you run this code from the console, "python.exe" is used to execute the code, but if you run it from IDLE (and probably other IDEs too), "pythonw.exe" is used. Both can be found in the folder in which Python is installed.

If you want it to run correctly, save the .py file onto your desktop (or anywhere else) and then double-click on it from there instead of running it in an IDE. The code will automatically be executed from the console and it will work fine.
Already been noted that the DLL runs okay from console but good to know only thing is White Fire has been gone for a week so we don't know if this works for what he wants or not.

we should also note this...
Quote:
Originally Posted by White Fire View Post

I never ran it through the idle. erggh
So... he's saying he ran it via console and still had problems. Someone want to troubleshoot that.
Edited by JQuantum - 8/12/12 at 8:15pm
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
post #27 of 28
He never said he ran it through the console. He just said he didn't use IDLE. He may be using some other IDE.
I'll see if I can get a hold of him over Steam.
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
 
Desktop
(13 items)
 
MacBook Pro 13"
(6 items)
 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
CPUGraphicsRAMHard Drive
Intel i5 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Lion 13.3" @ 1280 x 800 
  hide details  
Reply
post #28 of 28
Quote:
Originally Posted by {Unregistered} View Post

He never said he ran it through the console. He just said he didn't use IDLE. He may be using some other IDE.
I'll see if I can get a hold of him over Steam.

Sorry, that is true. I did assume if not IDLE must be console lol.
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
2012
(20 items)
 
Testing v2.5
(8 items)
 
 
CPUMotherboardGraphicsGraphics
Intel i7-3770k Gigabyte Z77X-UD5H MSI nVidia GTX 670 MSI nVidia GTX 670 
RAMHard DriveHard DriveHard Drive
Patriot Viper Xtreme DIV. 2 Samsung 830 OCZ Vertex 3 MAX IOPS OCZ Vertex 3 
Hard DriveOptical DriveOSOS
Seagate LG BluRay Windows 8 Professional x64 Mac OS X 10.8.1 (Pending) 
OSMonitorKeyboardPower
Fedora 17/Ubuntu 12.04 (Pending) Dell ST2220T Logitech G110 Corsair HX1050 
CaseMouseAudioOther
Corsair 600T Special Edition White Logitech G9x Unknown yet Keyboard: Corsair K90 (Pending) 
CPUMotherboardGraphicsRAM
Intel i5-3570k Asus P8Z77-i Deluxe MSI HD 7950 Samsung 
Hard DriveCoolingOSCase
OCZ Agility 3 Corsair H100i Windows 8 Professional x64 Cardboard box 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming